/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function(){  
    //LOADING POPUP  
    //Click the button event!  
    $("#loginLink").click(function(){  
        //centering with css  
        positionPopup();  
        //load popup  
        loadPopup();  
    });
    //CLOSING POPUP  
    //Click the x event!  
    $("#popupLoginClose").click(function(){  
        disablePopup();  
    });  
    //Click out event!  
    $("#backgroundPopup").click(function(){  
        disablePopup();  
    });
})

//SETTING UP OUR POPUP  
//0 means disabled; 1 means enabled;  
var popupLoginStatus = 0; 

//loading popup with jQuery magic!  
function loadPopup(){ 
    //loads popup only if it is disabled  
    if(popupLoginStatus==0){  
        $("#backgroundPopup").css({  
            "opacity": "0.7"  
        });  
        $("#backgroundPopup").fadeIn("slow");  
        $("#popupLogin").fadeIn("slow");  
        popupLoginStatus = 1;  
    }  
} 

//disabling popup with jQuery magic!  
function disablePopup(){  
    //disables popup only if it is enabled  
    if(popupLoginStatus==1){  
        $("#backgroundPopup").fadeOut("slow");  
        $("#popupLogin").fadeOut("slow");  
        popupLoginStatus = 0;  
    }  
} 

//centering popup  
function positionPopup(){  
    //request data for centering  
    var windowWidth = document.documentElement.clientWidth;  
    var windowHeight = document.documentElement.clientHeight;  
    var popupHeight = $("#popupLogin").height();  
    var popupWidth = $("#popupLogin").width();  
    //centering  
    $("#popupLogin").css({  
        "position": "absolute",  
        "top": 80,  
        "left": 700
    });  
    //only need force for IE6  
  
    $("#backgroundPopup").css({  
        "height": windowHeight  
    });  
}  